﻿package base.component
{
    import com.sh.game.util.*;
    import morn.core.components.*;

    public class ButtonImg extends Button
    {
        private var _img:Image;
        private var _imgskin:String = "";
        private var _arg:String = "left";
        private var _vag:String = "center";
        private var countLabel:Label;
        private var _imgretation:Number = 0;

        public function ButtonImg(param1:String = null, param2:String = "", param3:String = "", param4:String = "left", param5:String = "center")
        {
            this._imgskin = param3;
            this._arg = param4;
            this._vag = param5;
            super(param1, param2);
            this.countLabel = new Label();
            this.countLabel.font = "Simsun";
            this.countLabel.color = MColor.New62;
            this.countLabel.x = 150;
            this.countLabel.y = 5;
            this.addChild(this.countLabel);
            return;
        }// end function

        public function addCount(param1:int) : void
        {
            if (param1 > 0)
            {
                this.countLabel.text = "[" + param1 + "]";
            }
            else
            {
                this.countLabel.text = "";
            }
            return;
        }// end function

        override protected function createChildren() : void
        {
            super.createChildren();
            var _loc_1:* = new Image();
            this._img = new Image();
            addChild(_loc_1);
            return;
        }// end function

        public function imgRetation(param1:Number) : void
        {
            this._imgretation = param1;
            if (this._img)
            {
                this._img.rotation = this._imgretation;
                this._img.smoothing = true;
            }
            return;
        }// end function

        override protected function initialize() : void
        {
            super.initialize();
            return;
        }// end function

        public function imgVisible(param1:Boolean) : void
        {
            if (this._img)
            {
                this._img.visible = param1;
            }
            if (this._imgskin != "")
            {
                this._img.url = this._imgskin;
                if (this._arg == "center")
                {
                    this._img.x = this.width - this._img.width >> 2;
                }
                else if (this._arg == "right")
                {
                    this._img.x = this.width - this._img.width;
                }
                else
                {
                    this._img.x = 0;
                }
                if (this._vag == "center")
                {
                    this._img.y = this.height - this._img.height >> 2;
                }
                else if (this._vag == "bottom")
                {
                    this._img.y = this.height - this._img.height;
                }
                else
                {
                    this._img.y = 0;
                }
            }
            return;
        }// end function

    }
}
